GHDL = ghdl
ANALIZE = -a --ieee=synopsys -fexplicit
ELABORATE = -e --ieee=synopsys -fexplicit
RUN = -r

# agregar si tenes la app de 32 corriendo en 64 bits:
#  -a -Wc,-m32 -Wa,--32
#  -e -Wa,--32 -Wl,-m32

all:
	$(GHDL) $(ANALIZE) ../adder.vhdl
	$(GHDL) $(ANALIZE) ../flopr.vhdl
	$(GHDL) $(ANALIZE) ../mux2.vhdl
	$(GHDL) $(ANALIZE) ../sl2.vhdl
	$(GHDL) $(ANALIZE) ../signext.vhdl
	$(GHDL) $(ANALIZE) ../alu.vhdl
	$(GHDL) $(ANALIZE) ../aludec.vhdl
	$(GHDL) $(ANALIZE) ../maindec.vhdl
	$(GHDL) $(ANALIZE) ../controller.vhdl
	$(GHDL) $(ANALIZE) ../imem.vhdl
	$(GHDL) $(ANALIZE) ../dmem.vhdl
	$(GHDL) $(ANALIZE) ../regfile.vhdl
	$(GHDL) $(ANALIZE) ../fetch.vhdl
	$(GHDL) $(ANALIZE) ../decode.vhdl
	$(GHDL) $(ANALIZE) ../execute.vhdl
	$(GHDL) $(ANALIZE) ../memory.vhdl
	$(GHDL) $(ANALIZE) ../writeback.vhdl
	$(GHDL) $(ANALIZE) ../mips.vhdl

test:
# 	$(GHDL) $(ANALIZE) adder_tb.vhdl
# 	$(GHDL) $(ANALIZE) flopr_tb.vhdl
# 	$(GHDL) $(ANALIZE) mux2_tb.vhdl
# 	$(GHDL) $(ANALIZE) sl2_tb.vhdl
# 	$(GHDL) $(ANALIZE) signext_tb.vhdl
# 	$(GHDL) $(ANALIZE) alu_tb.vhdl
# 	$(GHDL) $(ANALIZE) aludec_tb.vhdl
# 	$(GHDL) $(ANALIZE) maindec_tb.vhdl
# 	$(GHDL) $(ANALIZE) imem_tb.vhdl
# 	$(GHDL) $(ANALIZE) dmem_tb.vhdl
# 	$(GHDL) $(ANALIZE) regfile_tb.vhdl
	$(GHDL) $(ANALIZE) mips_tb.vhdl
	
# 	$(GHDL) $(ELABORATE) adder_tb
# 	$(GHDL) $(ELABORATE) flopr_tb
# 	$(GHDL) $(ELABORATE) mux2_tb
# 	$(GHDL) $(ELABORATE) sl2_tb
# 	$(GHDL) $(ELABORATE) signext_tb
# 	$(GHDL) $(ELABORATE) alu_tb
# 	$(GHDL) $(ELABORATE) aludec_tb
# 	$(GHDL) $(ELABORATE) maindec_tb
# 	$(GHDL) $(ELABORATE) imem_tb
# 	$(GHDL) $(ELABORATE) dmem_tb
# 	$(GHDL) $(ELABORATE) regfile_tb
	$(GHDL) $(ELABORATE) mips_tb

# 	$(GHDL) $(RUN) adder_tb      --stop-time=100ns --vcd=adder_tb.vcd
# 	$(GHDL) $(RUN) flopr_tb      --stop-time=100ns --vcd=flopr_tb.vcd
# 	$(GHDL) $(RUN) mux2_tb       --stop-time=100ns --vcd=mux2_tb.vcd
# 	$(GHDL) $(RUN) sl2_tb        --stop-time=100ns --vcd=sl2_tb.vcd
# 	$(GHDL) $(RUN) signext_tb    --stop-time=100ns --vcd=signext_tb.vcd
# 	$(GHDL) $(RUN) alu_tb        --stop-time=100ns --vcd=alu_tb.vcd
# 	$(GHDL) $(RUN) aludec_tb     --stop-time=100ns --vcd=aludec_tb.vcd
# 	$(GHDL) $(RUN) maindec_tb    --stop-time=100ns --vcd=maindec_tb.vcd
# 	$(GHDL) $(RUN) imem_tb       --stop-time=100ns --vcd=imem_tb.vcd
# 	$(GHDL) $(RUN) dmem_tb       --stop-time=100ns --vcd=dmem_tb.vcd
# 	$(GHDL) $(RUN) regfile_tb    --stop-time=100ns --vcd=regfile_tb.vcd
	$(GHDL) $(RUN) mips_tb       --stop-time=100ns --vcd=mips_tb.vcd

clean:
	rm -rf *.s *.o *.cf *.lst *.vcd output.dump mips_tb